﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace treadmillProject.src.model {
    [Serializable()]
    public class TrainingData :ISerializable {
        public Pulse pulse;
        public Speed speed;
        public Gear gear;


        public TrainingData(Pulse pulse, Speed speed, Gear gear) {
            this.pulse = pulse;
            this.speed = speed;
            this.gear = gear;
            Console.WriteLine("TrainingData init...");
        }

        public TrainingData(SerializationInfo info, StreamingContext ctxt) {
            pulse = (Pulse) info.GetValue("Pulse", typeof (Pulse));
            speed = (Speed) info.GetValue("Speed", typeof (Speed));
            gear = (Gear) info.GetValue("Gear", typeof (Gear));
        }


        public void GetObjectData(SerializationInfo info, StreamingContext ctxt) {
            info.AddValue("Pulse", pulse);
            info.AddValue("Speed", speed);
            info.AddValue("Gear", gear);
        }


        public override string ToString() {
            return string.Format("Pulse: {0}, Speed: {1}, Gear: {2}", pulse.PulseData, speed.SpeedData, gear.GearData);
        }
    }
}